package com.varbal.icegame.mapper;

import com.varbal.icegame.entity.Apple;
import org.apache.ibatis.annotations.*;

/**
 * apple的curd
 */
//@Mapper//可被最外层的mapperscan替代扫描
public interface AppleMapper {

//    @Results({
//            @Result(property = "id", column = "id"),
//            @Result(property = "brand", column = "brand"),
//            @Result(property = "address", column = "address"),
//            @Result(property = "dealer", column = "dealer")
//    })
//
    @Select("select * from apple where id=#{id}")
    public Apple getById(int id);

    @Delete("delete from apple where id=#{id}")
    public int deleteById(int id);

    @Options(useGeneratedKeys = true,keyProperty = "id")//标志使用主键插入
    @Insert("insert into apple(id , brand , address , dealer) values(#{id},#{brand},#{address},#{dealer})")
    public int insertApple(Apple apple);

    @Update("update apple set brand = #{brand} , address = #{address} , dealer = #{dealer} where id = #{id}")
    public int updateApple(Apple apple);
}
